// T3.  2SLS Estimates of the Impact of Preprimary Enrollment on Child Outcomes
// T3.  2SLS Estimates of the Impact of Preprimary Enrollment on Child Outcomes
// T3.  2SLS Estimates of the Impact of Preprimary Enrollment on Child Outcomes


// PRELIMINARIES

clear
set more off
set scheme s1mono


// LOAD DATA
	
use "JakielaOzierFernaldKnauer-preschool-data.dta", replace


// IV REGRESSIONS:  IMPACT OF PRESCHOOL ON CHILD DEVELOPMENT

local outcome1 zluovocab
local outcome2 zengvocab
local outcome3 zexpvocab
local outcome4 zmotor
local outcome5 ecdindex


forvalues i = 1/5 {
	ivregress 2sls `outcome`i'' (inschool = schdist) if roundage==3, cluster(respid)
	mat V = r(table)
	local _beta`i' = string(V[1,1],"%04.3f")
	local _se`i' = string(V[2,1],"%04.3f")
	local _pval`i' = string(V[4,1],"%04.3f")
	local _obs`i' = e(N)
}

cap file close fh
file open fh using "out/T3-iv1.tex", write replace

file write fh "Enrolled in preprimary  & `_beta1' & `_beta2' & `_beta3' & `_beta4' & `_beta5' \\ " _newline
file write fh "		    & (`_se1') & (`_se2') & (`_se3') & (`_se4') & (`_se5') \\ " _newline
file write fh "		    & [`_pval1'] & [`_pval2'] & [`_pval3'] & [`_pval4'] & [`_pval5']  \\ " _newline

file close fh

cap file close fh
file open fh using "out/T3-ivinfo.tex", write replace

file write fh "Obs.  & `_obs1' & `_obs2' & `_obs3' & `_obs4' & `_obs5'  \\  " _newline

file close fh


local controls "i.childage haz male cgmom momeduc momluo hhsize sibs numassets haz_imputed dadabsent dadeduc dadluo missing_data i.schoolid"

forvalues i = 1/5 {
	ivregress 2sls `outcome`i'' (inschool = schdist) `controls' if roundage==3, cluster(respid)
	mat V = r(table)
	local _beta`i' = string(V[1,1],"%04.3f")
	local _se`i' = string(V[2,1],"%04.3f")
	local _pval`i' = string(V[4,1],"%04.3f")
	local _obs`i' = e(N)
}

cap file close fh
file open fh using "out/T3-iv2.tex", write replace

file write fh "Enrolled in preprimary  & `_beta1' & `_beta2' & `_beta3' & `_beta4' & `_beta5' \\ " _newline
file write fh "		     & (`_se1') & (`_se2') & (`_se3') & (`_se4') & (`_se5') \\ " _newline
file write fh "		     & [`_pval1'] & [`_pval2'] & [`_pval3'] & [`_pval4'] & [`_pval5']  \\ " _newline

file close fh


